package com.wjk.kylin.modules.system.dept.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.wjk.kylin.core.common.entity.BaseEntity;
import com.wjk.kylin.core.common.valid.insert;
import com.wjk.kylin.core.common.valid.update;
import lombok.Data;
import lombok.ToString;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 部门表
 * </p>
 *
 * @author wangjkui
 * @since 2020/5/22
 */
@Data
@ToString
@TableName("sys_dept")
public class Dept extends BaseEntity<Dept> {

    /** 父部门ID */
    @TableField("parent_id")
    private String parentId;

    /** 部门名称 */
    @NotBlank(message = "部门名称不能为空",groups = insert.class)
    @Size(min = 0, max = 30, message = "部门名称长度不能超过30个字符",groups = {insert.class, update.class})
    @TableField("name")
    private String name;

    /** 显示顺序 */
    @TableField("sort")
    private Integer sort;

    /** 负责人 */
    @TableField("leader")
    private String leader;

    /** 联系电话 */
    @Size(min = 0, max = 11, message = "联系电话长度不能超过11个字符",groups = {insert.class, update.class})
    @TableField("phone")
    private String phone;

    /** 邮箱 */
    @TableField("email")
    @Email(message = "邮箱格式不正确",groups = {insert.class, update.class})
    @Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符",groups = {insert.class, update.class})
    private String email;

    /** 部门状态:0正常,1停用 */
    @TableField("status")
    @Pattern(regexp="^[0-1]",message = "状态只能为0或1",groups = {insert.class, update.class})
    private String status;

    /** 子部门 */
    @TableField(exist = false)
    private List<Dept> children = new ArrayList<>();
}
